home *** CD-ROM | disk | FTP | other *** search
- // Super Heros Damage Dice
- // and Combat System
- #include <iostream.h>
- #include <iomanip.h>
- #include <process.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <time.h>
-
- // function prototypes
- int die_hero(int,int,int);
- int damage_menu(void);
- int main_menu(void);
- void line_draw(void);
- void detect_damage(int,int);
- void display_damage(int,int,int);
- void roll_dice(int dice,int damage);
-
- void main()
- { // begin main program
- int dice=0,mdice,damage,mdamage,choice1,choice2;
- int status;
-
- MAIN_MENU:
- while ((choice1 = main_menu()) != 6) { // begin while
- switch (choice1) { // begin menu select
- case 1:
- goto ENTER_DICE; // change dice
- break;
- case 2:
- if (dice==0) // begin if
- goto MAIN_MENU;
- // end if
- goto ROLL_DICE; // roll same dice
- break;
- case 3:
- dice=3; damage=2; // 3D6 roll
- goto ROLL_DICE;
- break;
- case 4:
- cout<<endl<<"Auto/Manual dice? (0/1): ";
- cin>>status;
- goto MAIN_MENU;
- break;
- case 5:
- exit(0); // quit program
- break;
- } // end menu
- } // end while
- goto MAIN_MENU;
-
- ENTER_DICE:
- clrscr(); cout<<"\nPlease enter number of dice (1 - 300) ? ";
- cin>>dice;
- if (dice<1 || dice>300) // begin if
- goto ENTER_DICE;
- // end if
-
- DAMAGE_MENU:
- while ((choice2 = damage_menu()) != 4) { // begin while
- switch (choice2) { // begin menu select
- case 1:
- damage=0; // killing damage
- mdice=dice; mdamage=damage;
- goto ROLL_DICE;
- break;
- case 2:
- damage=1; // normal damage
- mdice=dice; mdamage=damage;
- goto ROLL_DICE;
- break;
- case 3:
- goto MAIN_MENU; // main_menu()
- break;
- }// end menu
- } // end while
- goto DAMAGE_MENU;
-
- ROLL_DICE:
- detect_damage(dice,damage);
- if (status==0) // begin if
- cout<<setw(59)<<"[Auto Roll]";
- else // else
- cout<<setw(59)<<"[Space=Roll]";
- line_draw();
- roll_dice(dice,damage);
- dice=mdice; damage=mdamage;
-
- goto MAIN_MENU;
- }// end main program
-
- // function damage_menu()
- int damage_menu(void)
- {
- int choice2;
-
- clrscr();
- cout<<setw(45)<<"Damage Menu";
- line_draw();
- cout<<"Please enter a selection:";
- cout<<endl<<" 1 = Killing";
- cout<<endl<<" 2 = Normal";
- cout<<endl<<" 3 = Main Menu ? ";
- cin>>choice2;
- return choice2;
- }// end damage_menu()
-
- // function main_menu()
- int main_menu(void)
- {
- int choice1;
-
- clrscr();
- cout<<setw(44)<<"Main Menu";
- line_draw();
- cout<<"Please enter a selection:";
- cout<<endl<<" 1 = Change Dice";
- cout<<endl<<" 2 = Roll Same Dice";
- cout<<endl<<" 3 = 3D6 Roll";
- cout<<endl<<" 4 = Auto/Manual Dice";
- cout<<endl<<" 5 = Quit Program ? ";
- cin>>choice1;
- return choice1;
- }// end main_menu()
-
- // function roll_dice()
- void roll_dice(int dice,int damage)
- {
- int i,col,die,numdie,totaldice=0,normal=0;
- col=dice/10;
- randomize();
-
- for (numdie=1;numdie<=dice;numdie++) { // begin for
- die=die_hero(6,(300-dice)/5,1);
- cout<<die<<" ";
- if (col>1) { // begin if one
- if (numdie % col == 0) // begin if two
- cout<<"<-Rolls #"<<numdie+1-col<<" to "<<numdie-1/col<<endl;
- // end if two
- } // end if one
- if (col<2) // begin if
- cout<<"<-Roll #"<<numdie<<endl;
- // end if
- totaldice+=die;
- if (damage==1 && die==6) // begin if
- normal+=2;
- // end if
- if (damage==1 && die<6 && die>1) // begin if
- normal+=1;
- // end if
- } // end for
-
- line_draw();
- display_damage(damage,normal,totaldice);
-
- cout<<setw(39)<<"[Press any key]"<<endl;
- getche();
- }// end roll_dice
-
-